<?php
class Image extends AppModel{
	public $name='Image';	
	/*
	public $validate = array(
		'title' => array(array('rule'=>'notEmpty','message'=>'Can not be empty!'),
						array('rule'=>array('unique','title'),'message'=>'data is already existed'))		
	);*/
	public $actsAs = array('Translate'=>array('title'));


	 public $belongsTo = array(        
			'ImageCategory' => array(
			    'className'    => 'ImageCategory'
			)
    	);  
	    	
	// using app/Model/ProductCategory.php
	// In the following example, do not let a product category be deleted if it still contains products.
	// A call of $this->Product->delete($id) from ProductsController.php has set $this->id .
	// Assuming 'ProductCategory hasMany Product', we can access $this->Product in the model.
	public function beforeDelete($cascade = true) {
		//unbound
		App::uses('FileManager', 'Model');
		$FileManager= new FileManager();
		$data=$this->findById($this->id);				
		$FileManager->updateAll(array('mount'=>'mount - 1'),array('name'=>$data[$this->name]['image']));
		
	   return true;
	}
}
?>
